from django.conf.urls.defaults import *
from copy import deepcopy
from simplestats.models import PageView

info_dict = {
    'queryset': PageView.objects.all(),
    'date_field': 'time',
}
info_dict_month = deepcopy(info_dict)
info_dict_month.update({'month_format': '%m'})

urlpatterns = patterns('simplestats.views',
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', 'day_detail', name="stat_day"),
    url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', 'month_detail', name="stat_month"),
    url(
        r'^list/(?P<year>\d{4})/(?P<month>\d{1,2})/$',
        'custom_archive_month',
        info_dict_month,
        name="stat_archive_month"
    ),
    url(r'^(?P<year>\d{4})/$', 'year_detail', name="stat_year"),
    url(r'^$', 'index', name="stat_index"),
)

urlpatterns += patterns('django.views.generic.date_based',
    url(
        r'^list/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<object_id>\d+)/$',
        'object_detail',
        info_dict_month,
        name="stat_object_detail"
    ),
    url(
        r'^list/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$',
        'archive_day',
        info_dict_month,
        name="stat_archive_day"
    ),
    url(r'^list/(?P<year>\d{4})/$', 'archive_year', info_dict, name="stat_archive_year"),
    url(r'^list/$', 'archive_index', info_dict, name="stat_archive_index"),
)
